package com.jz.banner.screen.services

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.jz.banner.screen.ui.activity.LoginActivity
import com.jz.banner.screen.utils.CommUtils
import com.jz.banner.screen.utils.Urls


/**
 * 创建者     Noel
 * 创建时间   2019/4/22 10:46
 */

class MyReceiver : BroadcastReceiver() {

    companion object {
        private val TAG = MyReceiver::class.java.simpleName + "==>"
    }

    override fun onReceive(context: Context, intent: Intent) {
        val bundle = intent.extras
        //
        CommUtils.println(TAG, "onReceive:" + intent.action!!)
        when {
            //自启动
            intent.action == "android.intent.action.BOOT_COMPLETED" -> {
                if (Urls.SIGN_UPDATE_TYPE_BY_SHELL_INSTALL_RD != Urls.updateType) {
                    val i = Intent(context, LoginActivity::class.java)
                    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                    //因为开机启动太快，还没连上网。
                    context.startActivity(i)
                }
            }
        }
    }
}